var express = require('express');
var router = express.Router();// 路由
const OrdersApi = require("../api/order");

// 获取当页所有订单
router.get("/", async function (req, res, next) {
    const { curPage, eachPage } = req.query;
    const data = await OrdersApi.getOrder({ curPage, eachPage });
    res.send(data)
});

// 获取所有订单
router.get("/getUserOrder", async function (req, res, next) {
    const{id} = req.query;;
    const data = await OrdersApi.getUserOrder(id);
    res.send(data)
});
// 根据页码和每页显示的条数获取订单
router.get("/getUserOrderPage", async function (req, res, next) {
    const{userId,curPage,eachPage} = req.query;;
    const data = await OrdersApi.getUserOrderPage({userId,curPage,eachPage});
    res.send(data)
});

// 删除订单
router.post("/delOder", async function (req, res, next) {
    const{id} = req.body;;
    const data = await OrdersApi.delOder({id});
    res.send(data)
});
module.exports = router;

